'''
Created on 13 May 2013

@author: c03
'''

import praw
import time
import random

USER_AGENTS = ['super happy joyous bot',
               'fun and smiles v1.0', 
               'lolbot v1.25', 
               'funb0tz0rs happy', 
               'nice bots of random upvotes', 
               'randombot v1']
VERBOSE_MODE = True
REDDIT_USERS = {'d0wnr0t0r3':'downvoted',
                'd0wnr0t0r1':'downvoted',
                'd0wnr0t0r2':'downvoted'}
TARGET = "JohnJohn"
DOWNVOTES_PER_BOT = 2

def downvote(user, pswd, target, postsToDownvote):
    USER_AGENT = USER_AGENTS[random.randint(0,len(USER_AGENTS)-1)]
    r = praw.Reddit(user_agent=USER_AGENT)
    r.login(user, pswd)
    target = r.get_redditor(target)
    stuff = target.get_overview(limit=postsToDownvote)
    print("\n[+] Commencing downvote on: ["+str(target)+"] as USER: "+user+'['+USER_AGENT+']')
    for x in stuff:
        x.downvote()
        if VERBOSE_MODE:
            print("[*] Downvoted post: "+str(x))
        time.sleep(2.1)

def main():
    for user in REDDIT_USERS.keys():
        downvote(user, REDDIT_USERS[user],TARGET, DOWNVOTES_PER_BOT)

if __name__ == '__main__':
    main()